package exercise;

/**
 * @author shhjiang_001
 * @create 2020-07-07 18:57
 */
public class DesignMode {
}
// 线程安全的懒汉式单例模式
class Singleton{
    private Singleton(){}
    private static Singleton instance = null;
    public static Singleton getInstance() {
        if (instance == null){
            synchronized (Singleton.class){
                if (instance == null){
                    instance = new Singleton();
                }
            }
        }
        return instance;
    }
}
// 饿汉式单例模式
class ESingletone{
    private ESingletone(){}
    private static ESingletone instance = new ESingletone();
    public ESingletone getInstance(){
        return instance;
    }
}
